package view.dialogs;

import javax.swing.JPanel;

import view.components.HostComboBox;
import view.listeners.AddSubnetListener;
import view.listeners.CancelListener;
import view.listeners.HostBoxListener;
import view.views.dialogButtonViews.AddIpButtonPanel;
import view.views.dialogContentViews.AddSubnetContent;
import view.views.dialogContentViews.SubnetBoxPanel;

public class AddSubnetDialog extends Dialog {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private HostComboBox hostBox;
	private SubnetBoxPanel subnetBoxPanel;

	public AddSubnetDialog(String title) {
		super(title);

	}

	@Override
	protected JPanel addContent() {
		AddSubnetContent content = new AddSubnetContent();
		subnetBoxPanel = content.getSubnetBoxPanel();
		hostBox = content.getHostCombo();

		hostBox.getBox().addItemListener(
				new HostBoxListener(hostBox, subnetBoxPanel));

		return content;
	}

	@Override
	protected JPanel addButtons() {
		AddIpButtonPanel buttonPanel = new AddIpButtonPanel();
		buttonPanel.getCancelButton().addActionListener(
				new CancelListener(this));
		buttonPanel.getAddButton().addActionListener(
				new AddSubnetListener(this, subnetBoxPanel, hostBox));
		return buttonPanel;
	}

}
